﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Cash5
{
    public partial class NewShowAll : Form
    {
        private List<int[]> numbers;
        public NewShowAll(List<int[]> numbers)
        {
            this.numbers = numbers;
            
            InitializeComponent();
        }

        private void ShowAll_Load(object sender, EventArgs e)
        {
            var listSource = new List<Row>();
            var counter = 0;

            Row row = null;

            foreach (var number in numbers)
            {
                if(counter == 0)
                {
                    row = new Row();
                    row.Column1 = asString(number);
                }

                if (counter == 1)
                {
                    row.Column2 = asString(number);
                }

                if (counter == 2)
                {
                    row.Column3 = asString(number);
                }

                if (counter == 3)
                {
                    row.Column4 = asString(number);
                }

                if (counter == 4)
                {
                    row.Column5 = asString(number);
                    listSource.Add(row);
                    counter = -1;
                }


             

                counter++;
            }

            dataGridView1.DataSource = listSource;
        }

        private void btPrint_Click(object sender, EventArgs e)
        {
            //PrintDialog associate with PrintDocument;
            printDialog1.Document = printDocument1;

            if (printDialog1.ShowDialog() == DialogResult.OK)
            {
                printDocument1.Print();
            }
        }

        private string asString(int[] nums)
        {
            StringBuilder sb = new StringBuilder();
            bool first = true;
            for (int i = 0; i < nums.Length; i++)
            {
                if (!first) { sb.Append("-"); }
                sb.Append(nums[i]);
                first = false;
            }
            return sb.ToString();
        }

        private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
        {
            //e.Graphics.DrawArc();
//            e.Graphics.DrawString(textBox1.Text, textBox1.Font, Brushes.Black, 100, 20);
//            e.Graphics.PageUnit = GraphicsUnit.Inch;    

        }

        private void btPreview_Click(object sender, EventArgs e)
        {
            printPreviewDialog1.Document = printDocument1;

            //printPreviewDialog1.PrintPreviewControl.StartPage = 1;
            //printPreviewDialog1.P
           // printPreviewDialog1.PrintPreviewControl.Columns = 1;
            // Show PrintPreview Dialog
            printPreviewDialog1.ShowDialog();
        }
    }

    public class Row
    {
        public string Column1 { get; set; }
        public string Column2 { get; set; }
        public string Column3 { get; set; }
        public string Column4 { get; set; }
        public string Column5 { get; set; }
    }
}
